feat: add ESEARCH (RFC 4731) and PARTIAL (RFC 9394) support#347
Open
peterzen wants to merge 1 commit intopostalsys:masterfrom
Open
feat: add ESEARCH (RFC 4731) and PARTIAL (RFC 9394) support#347peterzen wants to merge 1 commit intopostalsys:masterfrom
peterzen wants to merge 1 commit intopostalsys:masterfrom
Conversation
Extend search() to accept returnOptions for efficient server-side result summarization. When the server advertises ESEARCH capability, emits UID SEARCH RETURN (...) and parses the ESEARCH untagged response into an ESearchResult object (count, min, max, all, partial). Key changes: - ESEARCH response parser (parseEsearchResponse) in search.js - RETURN clause builder with PARTIAL range support - Client-side ESearchResult derivation when server lacks ESEARCH - TypeScript ESearchResult interface and search() overloads - 13 nodeunit tests (parser, command builder, fallback, compat) Backward compatible: callers without returnOptions still receive number[] exactly as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds ESEARCH support to ImapFlow's
search()method, enabling efficient search result handling for large mailboxes.COUNT,MIN,MAX,ALL, andPARTIALresult keywords from* ESEARCHuntagged responsesUID SEARCH RETURN (COUNT PARTIAL 1:100 ...)whenreturnOptionsis passed and the server advertisesESEARCHcapabilityreturnOptionsget the samenumber[]result as beforeESearchResultclient-side from the plainnumber[](COUNT from.length, MIN/MAX from sorted ends, ALL viapackMessageRange) when the server lacks ESEARCHNew API
Motivation
For large mailboxes (70k+ messages),
client.search()currently returns every matching UID as anumber[], which is expensive to transfer and parse. ESEARCH allows:"1,5:10,20"instead of space-separated individual UIDsImplementation notes
connection.capabilities.has('ESEARCH'){type: 'LIST'}objects — the ESEARCH handler checks both forms for robustnessMODSEQfrom CONDSTORE) are silently skipped with correct stream alignmentreturnOptionsstrings are normalized to uppercase in both the command builder and fallback pathTested against